package com.zhongshengnetwork.rightbe.common;

import android.content.Context;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.viewpager.widget.ViewPager;

public class ChildViewPager extends ViewPager {
    int lastX = -1;     int lastY = -1;

    public ChildViewPager(Context context) {
        super(context);
    }

    public ChildViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return false;
        /*
        int x = (int) ev.getRawX();
        int y = (int) ev.getRawY();
        int dealtX = 0;
        int dealtY = 0;

        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN:
                getParent().requestDisallowInterceptTouchEvent(true);
                break;
                case MotionEvent.ACTION_MOVE:
                    dealtX += Math.abs(x - lastX);
                    dealtY += Math.abs(y - lastY);
                    lastX = x;
                    lastY = y;
                    if (dealtX >= dealtY) { // 左右滑动请求父不要需要拦截
                        getParent().requestDisallowInterceptTouchEvent(true);
                    } else {
                        getParent().requestDisallowInterceptTouchEvent(false);
                        return false;
                    }
                    break;
                 case MotionEvent.ACTION_CANCEL:
                        break;
                 case MotionEvent.ACTION_UP:
                        break;

        }
        return super.dispatchTouchEvent(ev);
        */
    }
}
